import { shopRequestClient } from '#/api/shop-request';

export namespace ShopGoodsApi {
  /** 商品SKU信息 */
  export interface GoodsSku {
    goods_id: number;
    sku_id: number;
    price: number;
    member_price?: number;
  }

  /** 商品信息 */
  export interface Goods {
    goods_id: number;
    site_id: number;
    goods_name: string;
    sub_title: string;
    goods_type: string;
    goods_cover: string;
    goods_cover_thumb_small: string;
    sale_num: number;
    status: number;
    stock: number;
    sort: number;
    goods_type_name: string;
    goods_edit_path: string;
    create_time: string;
    member_discount: string;
    is_gift?: any;
    goodsSku: GoodsSku;
  }

  /** 商品查询参数 */
  export interface GoodsQuery {
    page?: number;
    limit?: number;
    goods_name?: string;
    goods_type?: string;
    brand_id?: number;
    label_ids?: string;
    start_sale_num?: number;
    end_sale_num?: number;
    start_price?: number;
    end_price?: number;
    status?: number;
    order?: string;
    sort?: string;
  }

  /** 商品分页响应 */
  export interface GoodsPageResult {
    current_page: number;
    per_page: number;
    total: number;
    data: Goods[];
  }
}

/** 获取商品分页列表 */
export function getGoodsPage(params: ShopGoodsApi.GoodsQuery) {
  return shopRequestClient.get<ShopGoodsApi.GoodsPageResult>('/shop/goods', {
    params,
  });
}
